Skip to content

(hopefully) fixes some parts of the updater again#1867

Open
jensenhuangfan wants to merge 3 commits into
moeru-ai:mainfrom
jensenhuangfan:main
Open

(hopefully) fixes some parts of the updater again#1867
jensenhuangfan wants to merge 3 commits into
moeru-ai:mainfrom
jensenhuangfan:main

Conversation

@jensenhuangfan
Copy link
Copy Markdown
Contributor

Description

This PR resolves several critical issues across different platforms relating to our auto-updater and launcher behavior:

  1. macOS Updater Hang: Changed the app.exit(0) call in index.ts to app.quit(). This allows Electron's before-quit hooks to execute properly, enabling electron-updater to safely swap the binary payload and finish the installation instead of doing nothing when "Install" is clicked.
  2. Windows Silent Install Auto-Launch: Added runAfterFinish: true to the NSIS configuration in electron-builder.config.ts. This ensures the application automatically launches after a silent background update completes.
  3. Legacy Cache Pathing: Restored platform-specific OS cache resolution logic in getLegacyCacheRoot() (auto-updater.ts) to fix pathing errors and ensure backwards compatibility for older cache layouts during cleanup.

Linked Issues

#1626

Additional Context

  • Tested the Windows executable locally to confirm the silent update auto-launch flag works.
    I have a 2012 macbook pro with OCLP now and I can test release versions of airi but its too weak to build the versions on my device so i cant test at the moment on the mac.

fix(updater): resolve legacy cache pathing, Windows silent startup, a…
Copilot AI review requested due to automatic review settings May 23, 2026 23:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2026

⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.

Name Link
🔭 Waiting for approval For maintainers, approve here

Hey, maintainers, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Stage Tamagotchi’s Electron app shutdown flow and installer behavior, and adjusts legacy cache path resolution to be platform-appropriate.

Changes:

  • Implement platform-specific legacy cache root paths (Windows/macOS/Linux).
  • Change normal shutdown to use app.quit() while keeping abnormal shutdown as app.exit(1), and add a recursion guard in before-quit.
  • Configure NSIS installer to allow “run after finish”.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
apps/stage-tamagotchi/src/main/services/electron/auto-updater.ts Reworks legacy cache directory selection by platform/env vars.
apps/stage-tamagotchi/src/main/index.ts Adjusts exit strategy and before-quit handling to avoid re-entrancy.
apps/stage-tamagotchi/electron-builder.config.ts Enables running the app after installation completes.

Comment on lines +50 to +57
switch (process.platform) {
case 'win32':
return process.env.LOCALAPPDATA || join(process.env.USERPROFILE || '', 'AppData', 'Local')
case 'darwin':
return join(process.env.HOME || '', 'Library', 'Caches')
default:
return process.env.XDG_CACHE_HOME || join(process.env.HOME || '', '.cache')
}
Comment on lines 334 to 340
app.on('before-quit', (event) => {
if (appExiting)
return

event.preventDefault()
handleAppExit()
})
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5a027dc9e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

case 'darwin':
return join(process.env.HOME || '', 'Library', 'Caches')
default:
return process.env.XDG_CACHE_HOME || join(process.env.HOME || '', '.cache')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use absolute fallback paths for legacy cache root

When the expected environment variables are missing, this fallback builds relative paths (for example join('', '.cache') or join('', 'Library', 'Caches')). cleanupStaleUpdateFiles() later calls rm(..., { recursive: true, force: true }) on the derived updater cache directory, so in those environments it can delete a directory relative to the current working directory instead of the user cache location, and it will also miss the actual legacy cache directory. Use an absolute fallback such as app.getPath('home')/os.homedir() before appending cache segments.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants